//
//  BHHomeNavigationBar.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/6/8.
//

import UIKit
@objc protocol BHHomeNavigationBarDelegate: NSObjectProtocol {
    func didHomeNavigationBarDidSelect(type: Int)
}

class BHHomeNavigationBar: UIView {

    @IBOutlet weak var placeAreaBtn: UIButton!
    
    @IBOutlet weak var ringBtn: UIButton!
    
    @IBOutlet weak var redPoint: UILabel!
    
    var delegate: BHHomeNavigationBarDelegate?
    
    
    static func loadFromXib() -> BHHomeNavigationBar {
        let viewArray = Bundle.main.loadNibNamed("BHHomeNavigationBar", owner: nil, options: nil)
        let view: BHHomeNavigationBar = viewArray![0] as! BHHomeNavigationBar
        return view
    }
    
    
    override func awakeFromNib() {
        self.redPoint.addLayerCorner(3, 0, .color_FC352B)
        
        self.placeAreaBtn.addBtnAction(action: {[weak self] (_) in
            self?.delegate?.didHomeNavigationBarDidSelect(type: 0)
        }, for: .touchUpInside)
        
        self.ringBtn.addBtnAction(action: {[weak self] (_) in
            self?.delegate?.didHomeNavigationBarDidSelect(type: 1)
        }, for: .touchUpInside)
    }
}
